<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     
  
$eid=isset($_GET["eid"])?$_GET["eid"]:"";
$d=isset($_GET["d"])?$_GET["d"]:"";
if($eid!=''){
	$email=$T->db->query("select subject,content,attachment from sys_email where id={$eid}")->fetch(PDO::FETCH_ASSOC);
	if($email){
		if($d=='re'){
		    $T->Set("subject",'Re: '.$email['subject']);
		}
		if($d=='fw'){
			$attachment=$email['attachment'];
			if($attachment!=''){
				$attachment=explode(",", $attachment);
				foreach($attachment as $k=>$v){
					$attachment[$k]="'".$v."'";
				}
				$attachment=implode(",", $attachment);
				$attachment_info=$T->db->query("select id,name,save_path from sys_email_attachment where id in({$attachment}) order by `timestamp`")->fetchAll(PDO::FETCH_ASSOC);
			    $attachment_html="";
			    foreach($attachment_info as $k=>$v){
			    	$attachment_html.='<span class="attachment_span"><a class="attachment_one" href="'.$v['save_path'].'">'.$v['name'].'</a><a class="attachment_one_del" data-id="'.$v['id'].'">[删除]</a></span>';
    		    }
			    $T->Set("attachment_html",$attachment_html);
				$T->Set("attachment_arr",json_encode($attachment_info));
			}
			$T->Set("subject",'Fw: '.$email['subject']);
			$T->Set("content",htmlspecialchars_decode($email['content'],ENT_QUOTES));
		}
	}
}

$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 